package com.hcss.common.interceptor;

import com.hcss.common.constant.ConfigConstants;
import com.hcss.sys.role.dao.HcSysRoleComplexMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * @desc 拦截器配置类
 * @author maxiaoming
 * @date 2018年6月20日 下午4:48:41
 * @company 浙江鸿程计算机系统有限公司 
 */
@Configuration
public class InterceptorConfig extends WebMvcConfigurerAdapter{

    @Autowired
    private ConfigConstants configConstants;

    @Autowired
    private HcSysRoleComplexMapper hcSysRoleComplexMapper;

	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		registry.addInterceptor(new URLInterceptor(configConstants, hcSysRoleComplexMapper));
        //模块日志记录拦截器，preHandle按拦截器定义顺序执行,postHandle按拦截器定义逆序地调用
        //先通过URLIntercepror的权限认证，再走日志记录拦截器
        registry.addInterceptor(new URLInterceptorLog(hcSysRoleComplexMapper));
	}
}
